package com.lizhen.core.function.tika;

import org.apache.tika.Tika;

import java.io.File;
import java.io.IOException;

public class TikaDemo {

    private static final String FILE_PATH = "1.8\\api\\main\\resource\\com\\lizhen\\core\\function\\tika\\TikaDemo\\TikaDemo.xml";

    public TikaDemo() {
    }

    /*
     * @method main
     * @description
     * @author lizhen
     */
    public static void main(String[] args) {
        TikaDemo tikaDemo = new TikaDemo();
        tikaDemo.checkFileType();
    }

    /**
     * @author lizhen
     */
    private void checkFileType() {
        // assume example.mp3 is in your current directory
        File file = new File(FILE_PATH);
        // Instantiating tika facade class
        Tika tika = new Tika();
        try {
            // detecting the file type using detect method
            String filetype = tika.detect(file);

            System.out.println(filetype);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
